using System;
using System.Collections.Generic;
using System.Text;

namespace Mx.Ipn.Escom.TT20080015.Modelo.Memoria
{
    [Serializable]
    public class Asociacion
    {

        public int xSize, ySize;
        public List<byte> x;
        public List<byte> y;

        public Asociacion(int n, int p)
        {
            xSize = n;
            ySize = p;
            x = new List<byte>();
            y = new List<byte>();
        }
        public Asociacion(String input, String output)
        {
            x = new List<byte>();
            y = new List<byte>();
            for (int i = 0; i < input.Length; ++i)
                if (input[i] != '-')
                    x.Add(Convert.ToByte(input[i].ToString()));
                else if ((i + 1) < input.Length && char.IsDigit(input[i + 1]))
                {
                    x.Add(Convert.ToByte(input[i].ToString() + input[i + 1].ToString()));
                    ++i;
                }

            for (int i = 0; i < output.Length; ++i)
                if (output[i] != '-')
                    y.Add(Convert.ToByte(output[i].ToString()));
                else if ((i + 1) < output.Length && char.IsDigit(output[i + 1]))
                {
                    y.Add(Convert.ToByte(output[i].ToString() + output[i + 1].ToString()));
                    ++i;
                }
            xSize = x.Count;
            ySize = y.Count;
        }

        public override string ToString()
        {
            string strx = "";
            foreach (int xp in x) strx += xp;
            string stry = "";
            foreach (int yp in y) stry += yp;
            return strx + ";" + stry;
        }
    }
}